/* MapView */

#import <Cocoa/Cocoa.h>
#import "TileMap.h"
#import "TilePieceList.h"
#import "TileGroupList.h"
#import "TileList.h"
#import "ColorPalette.h"
#import "Unit.h"
#import "UnitList.h"
#import "DATManager.h"
#import "MiniMapView.h"
#import "Utility.h"
#import "LocationList.h"
#import "UnitEditController.h"
#import "NewUnitController.h"

enum MAP_MODE { 
	MAP_MODE_SELECTION,
	MAP_MODE_UNIT,
	MAP_MODE_TERRAIN
};

typedef enum MAP_MODE MAP_MODE;

@interface MapView : NSView
{
	TileMap			* _map;
	TilePieceList	* _pieceList;
	TileGroupList	* _groupList;
	TileList		* _tileList;
	ColorPalette	* _palette;
	UnitList		* _unitList;
	LocationList	* _locationList;
	BOOL			  _loadingCachedImage;
	
	NSMutableSet	* _selectedUnits;
	
	int selectedX;
	int selectedY;
	
	NSMutableArray	* _cachedBackgroundViews;
	int				numWide;
	int				numHigh;
	
	float			_scaleFactor;
	
	IBOutlet id		miniMapView;
	IBOutlet UnitEditController *    unitEditController;
	IBOutlet NewUnitController *     newUnitController;
	MAP_MODE		_mode;
}

- (void)setTileMap:(TileMap *)map;
- (void)setTilePieceList:(TilePieceList *)pieceList;
- (void)setTileGroupList:(TileGroupList *)groupList;
- (void)setTileList:(TileList *)tileList;
- (void)setPalette:(ColorPalette *)palette;
- (void)setUnitList:(UnitList *)unitList;
- (void)setLocationList:(LocationList *)locationList;

- (NSString *)coordinateValue;
- (void)drawSprite:(Sprite *)sprite forUnit:(Unit *)unit;
- (void)buildCachedImage:(id)context;

/* Scaling */
- (IBAction)changeScaleFactor:(id)sender;
- (void)setScaleFactor:(float)scale;
- (float)scaleFactor;

/* Bounding Rectangle */
- (NSRect)boundingRectangleForUnit:(Unit*)unit sprite:(Sprite *)sprite;
@end
